// eslint-disable-next-line rule
import messageCpt from "../components/public/message.vue"
import Vue from "vue"

function mjMessage ({ duration = 2500, text = '', mask = false, opacity = 0 }) {
  let MjMessage = Vue.extend(messageCpt)
  let mjMessage = new MjMessage().$mount()
  document.body.appendChild(mjMessage.$el)
  
  mjMessage.$on("finished", () => {
    mjMessage = null
  })
  
  mjMessage.show({ duration, text, mask, opacity })
  return mjMessage
}

export default mjMessage